﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LogicWaveWpf.UC
{
    /// <summary>
    /// LogicWave_uc.xaml 的交互逻辑
    /// </summary>
    public partial class LogicWave_uc : UserControl
    {
        public LogicWave_uc()
        {
            InitializeComponent();
            //var rd = new Random();
            double[] samples = new double[100];
            for (int i = 0; i < samples.Length; i++)
                samples[i] = i % 2;//rd.NextDouble();
            RenderWave(samples);
        }

        private void RenderWave(double[] samples)
        {
            var XScale = 20;
            var points = new PointCollection();
            for (int i = 0; i < samples.Length; i++)
            {
                double x = i * XScale;
                double y = samples[i]*20;//(samples[i] > 1) ? 1 : 0;
                points.Add(new Point(x, y));
            }
            SignalLine.Points = points;
        }

    }
}
